<?php
namespace App\Models;

use App\Models\BaseModel;

class UserAddress extends BaseModel
{
    protected $table = 'user_addresses';
    protected $fillable = [
        'province',
        'city',
        'district',
        'address',
        'zip',
        'contact_name',
        'contact_phone',
        'last_used_at',
    ];
    protected $dates = ['last_used_at'];

    public function user()
    {
        return $this->belongsTo('App\Models\User', 'id', 'uid');
    }

    /**
     * @desc 获取完整的地址
     * @return string
     */
    public function getFullAddressAttribute()
    {
        return "{$this->province}{$this->city}{$this->district}{$this->address}";
    }
}
